[Merged by Bors] - chore: fix diamonds around R and C structures#38451
[Merged by Bors] - chore: fix diamonds around R and C structures#38451sgouezel wants to merge 14 commits intoleanprover-community:masterfrom
Conversation
|
This pull request is now in draft mode. No active bors state needed cleanup. While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like |
PR summary 5b5173e00fImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
!radar |
|
Benchmark results for 3c79bc9 against 79540a7 are in. There are significant results. @sgouezel
Large changes (1✅)
Medium changes (2✅)
Small changes (10✅, 2🟥)
|
|
This pull request has conflicts, please merge |
|
!radar |
|
Benchmark results for eae998b against 5b5173e are in. There are significant results. @sgouezel
No significant changes detected. |
|
!radar |
|
Benchmark results for dc8867d against 5b5173e are in. No significant results found. @sgouezel
Small changes (6✅, 1🟥)
|
|
bors d+ |
|
✌️ sgouezel can now approve this pull request. To approve and merge a pull request, simply reply with |
This one is fixing a diamond which can not be encountered on master, but shows up after the fixes in #38451 (and fixing this diamond is necessary for #38451 to go through). The diamond is the following. If a space E is a C-module, then it is automatically an R-module (Module.complexToReal). Define now a type synonym E' to E, and declare that, if k acts on E, then it also acts on E', through `inferInstanceAs`. Then E' is a C-module (instance applied to k=C), and therefore an R-module by Module.complexToReal. But, as E is an R-module (by Module.complexToReal), then E' is also an R-module (by the instance applied to k=R). The two R-module structures are not the same implicit-reducibly, as the latter is hidden behind an opaque function crafted by `inferInstanceAs`. To avoid this, we define the `smul` field by hand instead of hiding it behind an opaque function. This should probably be done throughout Mathlib whenever a type synonym can be endowed with real and complex module structures. I'm just fixing one example here, because it's the one that breaks in #38451. Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
|
This PR/issue depends on: |
|
bors r+ |
The following examples fail on master, work with the PR:
```lean
example : (Semiring.toNatAlgebra : Algebra ℕ ℂ) = Complex.instAlgebraOfReal := by
with_reducible_and_instances rfl
example : (Ring.toIntAlgebra ℂ : Algebra ℤ ℂ) = Complex.instAlgebraOfReal := by
with_reducible_and_instances rfl
example : Module.restrictScalars ℝ ℂ ℂ = Complex.instModule := by
with_reducible_and_instances rfl
example : (instInnerProductSpaceRealComplex.toSMul : SMul ℝ ℂ) = Complex.instRCLike.toSMul := by
with_reducible_and_instances rfl
example {F : Type*} [NormedAddCommGroup F] [NormedSpace ℂ F] : SMulCommClass ℂ ℝ F :=
inferInstance
```
The PR makes a few algebra maps implicit-reducible. This is necessary to get rid of the diamonds as these maps show up in the instances. This has no noticeable performance impact: implicit-reducible only matters for instances, and there it tends to help unification.
Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr>
|
Pull request successfully merged into master. Build succeeded: |
The following examples fail on master, work with the PR:
The PR makes a few algebra maps implicit-reducible. This is necessary to get rid of the diamonds as these maps show up in the instances. This has no noticeable performance impact: implicit-reducible only matters for instances, and there it tends to help unification.
algebraMapfromAlgebrainstead of having a def #38430